package com.cube.truthseer.entity.bucket.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.cube.truthseer.common.exception.BadRequestException;
import com.cube.truthseer.entity.user.constants.UserErrorInfo;
import com.cube.truthseer.entity.user.enums.UserStatus;
import lombok.Getter;

@Getter
public enum BucketStatus {
    FROZEN(1, "禁止使用"),
    NORMAL(0, "已激活"),
    ;
    @EnumValue
    int value;
    String desc;

    BucketStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static BucketStatus of(int value) {
        if (value == 0) {
            return NORMAL;
        }
        if (value == 1) {
            return FROZEN;
        }
        throw new BadRequestException(UserErrorInfo.Msg.INVALID_USER_STATUS);
    }
}
